<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Released under the MIT License.
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------

namespace app\api\controller;

use think\request;
use think\cache\driver\Redis;
use cmf\controller\HomeBaseController;

class BaseController extends HomeBaseController
{
	protected $member_id;

	public function initialize()
    {
        parent::initialize();

        //检测是否已登录
        $token = $this->request->header('Authorization');
        if(!empty($token))
        {
            //存在，开始查找UID
            $redis =new Redis();
            $member_id = $redis->get($token);

            if(!empty($member_id))
            {
                $this->member_id = $member_id;
            }else{
                $this->error("token失效或已过期");
            }

        }else{
 			$this->error("您好，请先登录");
        }
	}
}



